package com.yaodian100.ec.rank.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

@Entity
@Table(name = "EC_VIEW_REPORT_PRODUCT_CLICK")
@NamedQueries({
			@NamedQuery(name = "ViewReportProductClick.getRankAfterDate", query = 
				"SELECT v.primaryKey.productId, " +//0
				"v.primaryKey.categoryId, " +//1
				"v.productName, " +//2
				"v.categoryName, " +//3
				"v.secondCategoryId, " +//4
				"v.secondCategoryName, " +//5
				"MIN(v.sort), " +//6
				"SUM(v.click) " +//7
				"from ViewReportProductClick v " +
				"where v.secondCategoryId=:secondCategoryId " +
				"and v.primaryKey.computeDate >= :computeDate " +
				"GROUP BY v.primaryKey.productId, " +
				"v.primaryKey.categoryId, " +
				"v.productName, " +
				"v.categoryName, " +
				"v.secondCategoryId, " +
				"v.secondCategoryName " +
				"order by MIN(v.sort) asc, " +
				"SUM(v.click) desc") 
				,@NamedQuery(name = "ViewReportProductClick.selectDistinctCategoryListAfterDateBySecondCategoryId", query = 
				"SELECT DISTINCT report.primaryKey.categoryId FROM ViewReportProductClick report WHERE report.secondCategoryId=:categoryId AND report.primaryKey.computeDate>=:computeDate")
		})
public class ViewReportProductClick {
	
	@EmbeddedId
	private ReportProductClickPrimaryKey primaryKey;
	
	@Column(name = "CLICK")
	private Long click;
	@Column(name = "MANUAL_SORT")
	private Long sort;
	@Column(name = "SECOND_CATEGORY_ID")
	private String secondCategoryId;
	@Column(name = "SECOND_CATEGORY_NAME")
	private String secondCategoryName;
	@Column(name = "CATEGORY_NAME")
	private String categoryName;
	@Column(name = "PRODUCT_NAME")
	private String productName;
	private BigDecimal shelfPrice;
	
	public ViewReportProductClick() {
		setPrimaryKey(new ReportProductClickPrimaryKey());
	}
		
	public Date getComputeDate() {
		return getPrimaryKey().getComputeDate();
	}
	public void setComputeDate(Date computeDate) {
		getPrimaryKey().setComputeDate(computeDate);
	}

	public ReportProductClickPrimaryKey getPrimaryKey() {
		return this.primaryKey;
	}
	public void setPrimaryKey(ReportProductClickPrimaryKey primaryKey) {
		this.primaryKey = primaryKey;
	}

	public Long getClick() {
		return this.click;
	}
	public void setClick(Long click) {
		this.click = click;
	}

	public Long getSort() {
		return this.sort;
	}
	public void setSort(Long sort) {
		this.sort = sort;
	}

	public String getSecondCategoryId() {
		return this.secondCategoryId;
	}
	public void setSecondCategoryId(String topCategoryId) {
		this.secondCategoryId = topCategoryId;
	}
	
	public String getSecondCategoryName() {
		return this.secondCategoryName;
	}
	public void setSecondCategoryName(String topCategoryName) {
		this.secondCategoryName = topCategoryName;
	}

	public String getCategoryName() {
		return this.categoryName;
	}
	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}
	
	public String getProductName() {
		return this.productName;
	}
	public void setProductName(String productName) {
		this.productName = productName;
	}

	public BigDecimal getShelfPrice() {
		return this.shelfPrice;
	}
	public void setShelfPrice(BigDecimal shelfPrice) {
		this.shelfPrice = shelfPrice;
	}

}
